window.onload = function() {
	var dataWidth = $("body").attr("data-width")
	var fun = {
		swiper: function() {
			var indexBanner = null;
			indexBanner = setInterval(function() {
				if ($('.banner-box .swiper-slide').length > 0) {
					var banner = new Swiper('.banner-box .swiper-container', {
						loop: true,
						autoplay: {
							delay: 5000,
							stopOnLastSlide: false,
							disableOnInteraction: true,
						},
					});
					clearInterval(indexBanner)
				}
			}, 300)


			


			if (dataWidth == "pc") {
				
				var swiperRecommen = null;
				swiperRecommen = setInterval(function() {
					if ($('.swiper-recommend .swiper-slide').length > 0) {
						var recommen = new Swiper('.swiper-recommend .swiper-container', {
							spaceBetween: 45,
							slidesPerView: 'auto',
							navigation: {
								nextEl: '.m-recommend .swiper-button-next',
								prevEl: '.m-recommend .swiper-button-prev',
							},
						});
						clearInterval(swiperRecommen)
					}
				}, 300)
				
				var swiperSelected = null;
				swiperSelected = setInterval(function() {
					if ($('.swiper-selected .swiper-slide').length > 0) {
						var selected = new Swiper('.swiper-selected .swiper-container', {
							spaceBetween: 20,
							slidesPerView: 'auto',
							navigation: {
								nextEl: '.m-selected .swiper-button-next',
								prevEl: '.m-selected .swiper-button-prev',
							},
						});
						clearInterval(swiperSelected)
					}
				}, 300)
				
				
				var swiperTeachers = null;
				swiperTeachers = setInterval(function() {
					if ($('.swiper-teachers .swiper-slide').length > 0) {
						var teachers = new Swiper('.swiper-teachers .swiper-container', {
							spaceBetween: 45,
							slidesPerView: 'auto',
							navigation: {
								nextEl: '.m-teachers .swiper-button-next',
								prevEl: '.m-teachers .swiper-button-prev',
							},
						});
						clearInterval(swiperTeachers)
					}
				}, 300)
				
			} else {
				var swiperRecommen = null;
				swiperRecommen = setInterval(function() {
					if ($('.swiper-recommend .swiper-slide').length > 0) {
						var recommen = new Swiper('.swiper-recommend .swiper-container', {
							spaceBetween: 0,
							slidesPerView: 'auto',
							navigation: {
								nextEl: '.m-recommend .swiper-button-next',
								prevEl: '.m-recommend .swiper-button-prev',
							},
						});
						clearInterval(swiperRecommen)
					}
				}, 300)
				
				var swiperTeachers = null;
				swiperTeachers = setInterval(function() {
					if ($('.swiper-teachers .swiper-slide').length > 0) {
						var teachers = new Swiper('.swiper-teachers .swiper-container', {
							spaceBetween: 0,
							slidesPerView: 'auto',
							navigation: {
								nextEl: '.m-teachers .swiper-button-next',
								prevEl: '.m-teachers .swiper-button-prev',
							},
						});
						clearInterval(swiperTeachers)
					}
				}, 300)
				
				var swiperCatalogue = null;
				swiperCatalogue = setInterval(function() {
					if ($('.m-catalogue-list .swiper-slide').length > 0) {
						var catalogue = new Swiper('.m-catalogue-list', {
							spaceBetween: 0,
							slidesPerView: 'auto',
						});
						clearInterval(swiperCatalogue)
					}
				}, 300)
			}

		},
		init: function() {
			if (dataWidth == "pc") {
				full();
			}
			$(".personal-box .change").click(function() {
				$(".personal-box .btn-outlined").show();
				$('div[read="true"] .input').removeAttr("readonly");
				$('div[read="true"]').attr("read", "false");
			})
			// 个人资料修改
			$(".personal-box .btn-outlined").click(function() {
				$(".personal-box .btn-outlined").hide();
				$('div[read="true"] .input').attr("readonly","readonly");
				$('div[read="false"]').attr("read", "true");
			})
			// 个人资料保存
			function pop(){
				var pops =$('div[pop="false"]').attr("pop");
				if (pops == "false") {
					$('div[pop="false"]').attr("pop", "true");
					$('div[screen="false"]').attr("screen", "full");
					full();
					$(".media-box .right-column").animate({
						height: "6rem"
					}, 350);
				} else{
					$('div[pop="true"]').attr("pop", "false");
					$('div[screen="full"]').attr("screen", "false");
					$(".media-box .right-column").animate({
						height: "0"
					}, 350);
				}
			}
			// 音频弹窗
			$(".wap-column .pop-btn,.wap-column .y-mask").click(function() {
				 pop()
			})
			$(".wap-column .m-item-box .items").click(function() {
				var index = $(this).index();
				$(this).addClass("current").siblings().removeClass("current");
				$(".media-box .right-column>div").eq(index).addClass("current").siblings().removeClass("current");
				var pops =$('div[pop="false"]').attr("pop");
				if (pops == "false") {
					pop()
				}
			})
			// wap音频弹框切换
			// pc讲师更多
			$(".media-box .teacher-box .y-btn").click(function(){
				var btn=$('div[opn="false"]').attr("opn");
				if(btn == "false"){
					$(this).text("收起").attr("opn", "true");
					$(".media-box .teacher-box .y-con").css("height","auto");
					
				}else{
					$(this).text("加载更多").attr("opn", "false");
					$(".media-box .teacher-box .y-con").css("height","1.2rem")
				}
			})
			// 视频弹窗
			$(".video-box .m-video-syn .syn-btn").click(function() {
				 var pops =$('div[pop="false"]').attr("pop");
				 if (pops == "false") {
				 	$('div[pop="false"]').attr("pop", "true");
				 	$('div[screen="false"]').attr("screen", "full");
				 	full();
				 	$(".media-box .right-column").animate({
				 		bottom: "0"
				 	}, 350);
				 } else{
				 	$('div[pop="true"]').attr("pop", "false");
				 	$('div[screen="full"]').attr("screen", "false");
				 	$(".media-box .right-column").animate({
				 		bottom: "-100%"
				 	}, 350);
				 }
			})
			$(".video-box .catalogue-btn").click(function(){
				var opens =$('div[opens="false"]').attr("opens");
				if (opens == "false") {
					$('div[opens="false"]').attr("opens", "true");
					$('div[screen="false"]').attr("screen", "full");
					full();
				} else{
					$('div[opens="true"]').attr("opens", "false");
					$('div[screen="full"]').attr("screen", "false");
				}
			})
			
			function full() {
				$('div[screen="full"]').height($(window).height())
			}

			$(window).scroll(function() {
				goTop();
			});

			function goTop() {
				var scrollTop = $(window).scrollTop();
				// if (scrollTop > 1200 && scrollTop < 1250) {
				// 	$(".timer").each(count);
				// }
				if (scrollTop > 0) {
					$(".goTop").show();
				} else {
					$(".goTop").hide();
				}
			}
			$('.goTop').click(function() {
				if ($(window).scrollTop() > 0) {

					$('body,html').animate({
						scrollTop: 0
					}, 800);
				}
			});
		}
	}

	fun.swiper(); /* 轮播函数 */
	fun.init();

}
